Implement copy_to_image instead of get_image
authorAlex Larsson <alexl@redhat.com>
Fri, 25 Jan 2002 17:10:03 +0000 (17:10 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Fri, 25 Jan 2002 17:10:03 +0000 (17:10 +0000)
2002-01-25  Alex Larsson  <alexl@redhat.com>

* gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
Implement copy_to_image instead of get_image

* gdk/linux-fb/gdkimage-fb.c:
Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
_gdk_fb_copy_to_image.
Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>

* gdk/linux-fb/gdkmain-fb.c:
Make ENABLE_FB_MANAGER region larger.

* gdk/linux-fb/gdkprivate-fb.h:
Change _gdk_fb_get_image to _gdk_fb_copy_to_image.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/linux-fb/gdkdrawable-fb2.c
gdk/linux-fb/gdkimage-fb.c
gdk/linux-fb/gdkmain-fb.c
gdk/linux-fb/gdkprivate-fb.h

index 4fd63041e5d6147fe3de40342a09dfdb880110c8..3e352c3df7b13eecccd10fcabb5f98e28f343b30 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2002-01-25  Alex Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
+       Implement copy_to_image instead of get_image
+       
+       * gdk/linux-fb/gdkimage-fb.c:
+       Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
+       _gdk_fb_copy_to_image.
+       Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
+
+       * gdk/linux-fb/gdkmain-fb.c:
+       Make ENABLE_FB_MANAGER region larger.
+
+       * gdk/linux-fb/gdkprivate-fb.h:
+       Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
+
 2002-01-25  Sven Neumann  <sven@gimp.org>
 
        * gtk/gtkwindow.c (gtk_window_get_size): changed the comment so
index 4fd63041e5d6147fe3de40342a09dfdb880110c8..3e352c3df7b13eecccd10fcabb5f98e28f343b30 100644 (file)
@@ -1,3 +1,19 @@
+2002-01-25  Alex Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
+       Implement copy_to_image instead of get_image
+       
+       * gdk/linux-fb/gdkimage-fb.c:
+       Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
+       _gdk_fb_copy_to_image.
+       Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
+
+       * gdk/linux-fb/gdkmain-fb.c:
+       Make ENABLE_FB_MANAGER region larger.
+
+       * gdk/linux-fb/gdkprivate-fb.h:
+       Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
+
 2002-01-25  Sven Neumann  <sven@gimp.org>
 
        * gtk/gtkwindow.c (gtk_window_get_size): changed the comment so
index 4fd63041e5d6147fe3de40342a09dfdb880110c8..3e352c3df7b13eecccd10fcabb5f98e28f343b30 100644 (file)
@@ -1,3 +1,19 @@
+2002-01-25  Alex Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
+       Implement copy_to_image instead of get_image
+       
+       * gdk/linux-fb/gdkimage-fb.c:
+       Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
+       _gdk_fb_copy_to_image.
+       Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
+
+       * gdk/linux-fb/gdkmain-fb.c:
+       Make ENABLE_FB_MANAGER region larger.
+
+       * gdk/linux-fb/gdkprivate-fb.h:
+       Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
+
 2002-01-25  Sven Neumann  <sven@gimp.org>
 
        * gtk/gtkwindow.c (gtk_window_get_size): changed the comment so
index 4fd63041e5d6147fe3de40342a09dfdb880110c8..3e352c3df7b13eecccd10fcabb5f98e28f343b30 100644 (file)
@@ -1,3 +1,19 @@
+2002-01-25  Alex Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
+       Implement copy_to_image instead of get_image
+       
+       * gdk/linux-fb/gdkimage-fb.c:
+       Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
+       _gdk_fb_copy_to_image.
+       Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
+
+       * gdk/linux-fb/gdkmain-fb.c:
+       Make ENABLE_FB_MANAGER region larger.
+
+       * gdk/linux-fb/gdkprivate-fb.h:
+       Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
+
 2002-01-25  Sven Neumann  <sven@gimp.org>
 
        * gtk/gtkwindow.c (gtk_window_get_size): changed the comment so
index 4fd63041e5d6147fe3de40342a09dfdb880110c8..3e352c3df7b13eecccd10fcabb5f98e28f343b30 100644 (file)
@@ -1,3 +1,19 @@
+2002-01-25  Alex Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
+       Implement copy_to_image instead of get_image
+       
+       * gdk/linux-fb/gdkimage-fb.c:
+       Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
+       _gdk_fb_copy_to_image.
+       Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
+
+       * gdk/linux-fb/gdkmain-fb.c:
+       Make ENABLE_FB_MANAGER region larger.
+
+       * gdk/linux-fb/gdkprivate-fb.h:
+       Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
+
 2002-01-25  Sven Neumann  <sven@gimp.org>
 
        * gtk/gtkwindow.c (gtk_window_get_size): changed the comment so
index 4fd63041e5d6147fe3de40342a09dfdb880110c8..3e352c3df7b13eecccd10fcabb5f98e28f343b30 100644 (file)
@@ -1,3 +1,19 @@
+2002-01-25  Alex Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
+       Implement copy_to_image instead of get_image
+       
+       * gdk/linux-fb/gdkimage-fb.c:
+       Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
+       _gdk_fb_copy_to_image.
+       Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
+
+       * gdk/linux-fb/gdkmain-fb.c:
+       Make ENABLE_FB_MANAGER region larger.
+
+       * gdk/linux-fb/gdkprivate-fb.h:
+       Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
+
 2002-01-25  Sven Neumann  <sven@gimp.org>
 
        * gtk/gtkwindow.c (gtk_window_get_size): changed the comment so
index 4fd63041e5d6147fe3de40342a09dfdb880110c8..3e352c3df7b13eecccd10fcabb5f98e28f343b30 100644 (file)
@@ -1,3 +1,19 @@
+2002-01-25  Alex Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
+       Implement copy_to_image instead of get_image
+       
+       * gdk/linux-fb/gdkimage-fb.c:
+       Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
+       _gdk_fb_copy_to_image.
+       Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
+
+       * gdk/linux-fb/gdkmain-fb.c:
+       Make ENABLE_FB_MANAGER region larger.
+
+       * gdk/linux-fb/gdkprivate-fb.h:
+       Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
+
 2002-01-25  Sven Neumann  <sven@gimp.org>
 
        * gtk/gtkwindow.c (gtk_window_get_size): changed the comment so
index 4c5cfd2f7cd65f159b469a3d6bbd3db442a81e08..c44279e7c53e2aec6dc4c614afcf0048bb37b201 100644 (file)
@@ -221,7 +221,7 @@ gdk_drawable_impl_fb_class_init (GdkDrawableFBClass *klass)
   drawable_class->get_depth = gdk_fb_get_depth;
   drawable_class->get_visual = gdk_fb_get_visual;
   
-  drawable_class->get_image = _gdk_fb_get_image;
+  drawable_class->_copy_to_image = _gdk_fb_copy_to_image;
 }
 
 static void
index dff16fbb52a195f8ff63a0ae5a305f0766d042a6..7c803fa5607fa948e8f0b15c0de4b2040b5084f6 100644 (file)
@@ -103,6 +103,41 @@ gdk_image_get_type (void)
   return object_type;
 }
 
+
+GdkImage*
+_gdk_image_new_for_depth (GdkImageType  type,
+                         GdkVisual    *visual,
+                         gint          width,
+                         gint          height,
+                         gint          depth)
+{
+  GdkImage *image;
+  GdkImagePrivateFB *private;
+
+  g_return_val_if_fail (!visual || GDK_IS_VISUAL (visual), NULL);
+  g_return_val_if_fail (visual || depth != -1, NULL);
+
+  if (visual)
+    depth = visual->depth;
+
+  image = g_object_new (gdk_image_get_type (), NULL);
+  private = GDK_IMAGE_PRIVATE_DATA (image);
+
+  image->type = 0;
+  image->visual = visual;
+  image->width = width;
+  image->height = height;
+  image->depth = depth;
+  
+  image->byte_order = 0;
+  image->bits_per_pixel = image->depth;
+  image->bpp = image->depth/8;
+  image->bpl = (width * image->depth + 7) / 8;
+  image->mem = g_malloc (image->bpl * height);
+
+  return image;
+}
+
 GdkImage *
 gdk_image_new_bitmap(GdkVisual *visual,
                     gpointer data,
@@ -141,35 +176,19 @@ gdk_image_new (GdkImageType  type,
               gint          width,
               gint          height)
 {
-  GdkImage *image;
-  GdkImagePrivateFB *private;
-
-  image = g_object_new (gdk_image_get_type (), NULL);
-  private = GDK_IMAGE_PRIVATE_DATA (image);
-
-  image->type = 0;
-  image->visual = visual;
-  image->width = width;
-  image->height = height;
-  image->depth = visual->depth;
-  
-  image->byte_order = 0;
-  image->bits_per_pixel = image->depth;
-  image->bpp = image->depth/8;
-  image->bpl = (width * image->depth + 7) / 8;
-  image->mem = g_malloc (image->bpl * height);
-
-  return image;
+  return _gdk_image_new_for_depth (type, visual, width, height, -1);
 }
 
 GdkImage*
-_gdk_fb_get_image (GdkDrawable *drawable,
-                  gint       x,
-                  gint       y,
-                  gint       width,
-                  gint       height)
+_gdk_fb_copy_to_image (GdkDrawable    *drawable,
+                      GdkImage       *image,
+                      gint            src_x,
+                      gint            src_y,
+                      gint            dest_x,
+                      gint            dest_y,
+                      gint            width,
+                      gint            height)
 {
-  GdkImage *image;
   GdkImagePrivateFB *private;
   GdkPixmapFBData fbd;
   GdkRegion *region = NULL;
@@ -177,28 +196,35 @@ _gdk_fb_get_image (GdkDrawable *drawable,
 
   g_return_val_if_fail (drawable != NULL, NULL);
 
-  image = g_object_new (gdk_image_get_type (), NULL);
+  if (image == NULL)
+    {
+      image = g_object_new (gdk_image_get_type (), NULL);
+
+      image->type = GDK_IMAGE_NORMAL;
+      image->visual = gdk_drawable_get_visual (drawable);
+      image->width = width;
+      image->height = height;
+      image->bits_per_pixel = GDK_DRAWABLE_FBDATA (drawable)->depth;
+      image->depth = image->bits_per_pixel;
+      
+      if (image->bits_per_pixel <= 8)
+       image->bpp = 1;
+      else if (image->bits_per_pixel <= 16)
+       image->bpp = 2;
+      else if (image->bits_per_pixel <= 24)
+       image->bpp = 3;
+      else
+       image->bpp = 4;
+      image->byte_order = 1;
+
+      image->bpl = (image->width * image->depth + 7) / 8; /* Packed pixels */
+      image->mem = g_malloc (image->bpl * image->height);
+
+      dest_x = 0;
+      dest_y = 0;
+    }
+  
   private = GDK_IMAGE_PRIVATE_DATA (image);
-
-  image->type = GDK_IMAGE_NORMAL;
-  image->visual = gdk_drawable_get_visual (drawable);
-  image->width = width;
-  image->height = height;
-  image->bits_per_pixel = GDK_DRAWABLE_FBDATA (drawable)->depth;
-  image->depth = image->bits_per_pixel;
-
-  if (image->bits_per_pixel <= 8)
-    image->bpp = 1;
-  else if (image->bits_per_pixel <= 16)
-    image->bpp = 2;
-  else if (image->bits_per_pixel <= 24)
-    image->bpp = 3;
-  else
-    image->bpp = 4;
-  image->byte_order = 1;
-
-  image->bpl = (image->width * image->depth + 7) / 8; /* Packed pixels */
-  image->mem = g_malloc (image->bpl * image->height);
   
   /* Fake its existence as a pixmap */
   memset (&fbd, 0, sizeof(fbd));
@@ -224,8 +250,8 @@ _gdk_fb_get_image (GdkDrawable *drawable,
   gdk_fb_draw_drawable_2 ((GdkPixmap *)&fbd,
                          _gdk_fb_screen_gc,
                          drawable,
-                         x, y,
-                         0, 0,
+                         src_x, src_y,
+                         dest_x, dest_y,
                          width, height,
                          TRUE, TRUE);
 
@@ -314,3 +340,19 @@ void
 _gdk_image_exit(void)
 {
 }
+
+/* copy/pasted from gdkimage-win32.c */
+gint
+_gdk_windowing_get_bits_for_depth (gint depth)
+{
+  if ((1 == depth) || (8 == depth) || (16 == depth) || 
+      (24 == depth) || (32 == depth))
+    return depth;
+  else if (15 == depth)
+    return 16;
+  else
+    g_assert_not_reached ();
+
+  return 0;    
+}
+
index e20fa369e3e98e937514ad6aa2f82d3fbf7f55a6..372f80c76b07b3e45def7f16675e7cc48c735ff2 100644 (file)
@@ -567,6 +567,7 @@ gdk_fb_manager_callback (GIOChannel *gioc,
 static void
 gdk_fb_manager_connect (GdkFBDisplay *display)
 {
+#ifdef ENABLE_FB_MANAGER
   int fd;
   struct sockaddr_un addr;
   struct msghdr msg = {0};
@@ -581,7 +582,6 @@ gdk_fb_manager_connect (GdkFBDisplay *display)
   display->manager_blocked = FALSE;
   display->manager_fd = -1;
 
-#ifdef ENABLE_FB_MANAGER
   fd = socket (PF_UNIX, SOCK_STREAM, 0);
   
   g_print ("socket: %d\n", fd);
index 40cfabc8a39a8f78ee4311c793ea324d57186e0d..e8741f4aabfee87249ea7edfff05988ebf99f4ef 100644 (file)
@@ -308,11 +308,14 @@ GdkGC *   _gdk_fb_gc_new                      (GdkDrawable     *drawable,
 void      _gdk_fb_gc_calc_state              (GdkGC           *gc,
                                              GdkGCValuesMask  changed);
 
-GdkImage *_gdk_fb_get_image                  (GdkDrawable     *drawable,
-                                             gint             x,
-                                             gint             y,
-                                             gint             width,
-                                             gint             height);
+GdkImage *_gdk_fb_copy_to_image              (GdkDrawable    *drawable,
+                                             GdkImage       *image,
+                                             gint            src_x,
+                                             gint            src_y,
+                                             gint            dest_x,
+                                             gint            dest_y,
+                                             gint            width,
+                                             gint            height);
 void      gdk_fb_drawable_clear              (GdkDrawable     *drawable);
 void      gdk_fb_draw_drawable               (GdkDrawable     *drawable,
                                              GdkGC           *gc,